Trivia API

Code Quality & Documentation

Criteria Meet Specification

Write clear, concise and well documented code

The code adheres to the PEP 8 style guide and follows common best practices, including:

Write an informative README File

README includes:

  • Instructions for how to install project dependencies and start the project server.
  • Detailed documentation of API endpoints and expected behavior, using the format taught in the course:
    • METHOD Url
      • Request parameters
      • Response body

Leverage environment controls

Local files and virtual environment are included in .gitignore file

Handling HTTP Requests

Criteria Meet Specification

Follow RESTful principles

RESTful principles are followed throughout the project, including appropriate naming of endpoints, use of HTTP methods GET, POST, and DELETE.

Routes perform CRUD operations on the psql database

Utilize multiple HTTP request methods

Complete all TODO flags in backend/app.py :

  • Endpoint to handle GET requests for questions, including pagination (every 10 questions). This endpoint should return a list of questions, number of total questions, current category, categories.
  • Endpoint to handle GET requests for all available categories.
  • Endpoint to DELETE question using a question ID.
  • Endpoint to POST a new question, which will require the question and answer text, category, and difficulty score.
  • Create a POST endpoint to get questions based on category.
  • Create a POST endpoint to get questions based on a search term. It should return any questions for whom the search term is a substring of the question.
  • Create a POST endpoint to get questions to play the quiz. This endpoint should take category and previous question parameters and return a random questions within the given category, if provided, and that is not one of the previous questions.

Handle common errors

Project handles common errors using the @app.errorhandler decorator function to format an API friendly JSON error response

Passes all provided tests related to error handling

API Testing & Documentation

Criteria Meet Specification

Use unittest to test flask application for expected behavior

Import and utilize unittest library to test each endpoint for expected success and error behavior. Each endpoint should have at one test for the expected behavior and tests for error handling if applicable.

Demonstrate validity of API responses

Project includes tests to ensure CRUD operations are successful and persist accurately in the database for GET, POST, PUT and DELETE HTTP requests.

Tips to make your project standout:

  1. Add an additional question field such as rating and make all corresponding updates (db, api endpoints, add question form, etc.)

  2. INTENSE: Add users to the DB and track their game scores

  3. Add capability to create new categories.